package com.lengyu.iottransfer.gateway.tcp.sanyuanShuibiao;

import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.bytes.ByteArrayDecoder;
import io.netty.handler.codec.bytes.ByteArrayEncoder;

public class BootNettyChannelInitializer<SocketChannel> extends ChannelInitializer<Channel> {

    @Override
    protected void initChannel(Channel ch) throws Exception {

        // ChannelOutboundHandler，依照逆序执行
        ch.pipeline().addLast("bytesDecoder", new ByteArrayDecoder());

        // 属于ChannelInboundHandler，依照顺序执行
        ch.pipeline().addLast("bytesEncoder", new ByteArrayEncoder());

//        ch.pipeline().addLast(new TcpOutBoundHandler());
        /**
         * 自定义ChannelInboundHandlerAdapter
         */
        ch.pipeline().addLast(new SanyuanBootNettyChannelInboundHandlerAdapter());

    }

}